<head>
<?php echo $html->css('estilosAux'); ?>
<script>
var $j = jQuery.noConflict(); 
$j(document).ready(function(){

$j('#loginForm').validate({
	rules:
	{
		"data[User][username]":{
			required:true,
			number:true,
			minlength:6,
			maxlength:8
		},
		"data[User][password]":{
			required:true
		}
	},
	messages:{
		"data[User][username]":{
			required:"Obligatorio",
			number:"Num&eacute;rico",
			minlength:"M&iacute;nimo 6 d&iacute;gitos",
			minlength:"M&iacute;nimo 8 d&iacute;gitos"
		},
		"data[User][password]":{
			required:"Obligatorio"
		}
	}
});

var options={
	target:'#formlogin',
	beforeSubmit: function(formData, jqForm,options)
	{
		if($j('#UserUsername').val()=="")
		{
			alert("Debe Ingresar Su nombre de Usuario");
			$j('#UserUsername').focus();
			return false;
		}
	},
	success: function(responseText, statusText, xhr, $jform)
	{}	
	}
	$j('#loginsistema').live("click",function(){
		var isValid=jQuery('#loginForm').valid();
		if(isValid==true){
			$j('#loginForm').ajaxForm(options);
		}
	})
	
})
</script>
</head>
<div id="login" class="loginuser">
<div id="formlogin" class="fondologin">
<?php
	if (isset($closeModalbox) && $closeModalbox) echo "<div id='closeModalbox'></div>";
		if ($ajax->isAjax()) 
		{
			echo $ajax->form('login', 'user', array(
				'model'    => 'User',
				'url'      => array('controller' => 'users', 'action' => 'login'),
				'update'   => 'MB_content',
				'id'=>'loginForm'
				));
		} 
		else 
		{
			echo $form->create('User',array('action'=>'login','id'=>'loginform'));
		}

?>

<?php
	//echo $form->create('User',array('controller'=>'users','action'=>'login'));
	echo "<div class='loginlabel'>";
		echo $session->read('long');
	echo "</div>";
	?>
	<div id="textologinclave" class="textologinclave">
		<?php echo "C&eacute;dula"; ?>
	</div>
	<?php
	echo $form->input('User.username',array('label'=>'','class'=>'entrada16','value'=>'','onblur'=>'clearText(this)','onfocus'=>'clearText(this)'));
		?>
		<div id="textologinclave" class="textologinclave">
			<?php
				echo "Clave";
			?>
		</div>
		<?php
			echo $form->input('User.password',array('label'=>'','class'=>'entrada16','value'=>''));
			echo $form->submit('Ingresar',array('class'=>'botonlogin','id'=>'loginsistema')); 
			echo $form->end();
		?>
		
	<div id="textologin" class="textologin">
	<?php	
		echo $form->label('<br/> Olvid&oacute; su clave ');
		echo $html->link($html->image('click.jpg'), 
			array(
				'controller'=>'users',
				'action'=>'recuperar'),
					array(
						'title'=>'Recupera tu Clave',
						'onclick'=> "Modalbox.show(this.href, {title: this.title, width: 460, height:250}); return false;",
						'escape'=>false
						)
						);
		echo $form->label('<br/> No te haz registrado ');
		echo $html->link($html->image('click.jpg'), 
			array(
				'controller'=>'clientes',
				'action'=>'add'),
					array(
						'title'=>'',
						'onclick'=> "Modalbox.show(this.href, {title: this.title, width: 500, height:800}); return false;",
						'escape'=>false
						)
						);
	?>	
	</div>	
	<?php
    //echo $form->end();
	?>
</div>
</div>